<%inherit file="/base.html"/>
<%block name="content">
<div class="king-block king-block-bordered king-block-themed m20">
    <div class="king-block-header king-info">
        <ul class="king-block-options">
            <li>
                <!-- <button type="button"><i class="fa fa-cog"></i></button> -->
            </li>
        </ul>
        <h3 class="king-block-title">会议内容录入</h3>
    </div>
    <div class="king-block-content">
        <form class="form-horizontal">
            <div class="form-group clearfix ">
                <label class="col-sm-3 control-label bk-lh30 pt0">主题：</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control bk-valign-top" id="theme" placeholder="会议主题"> </div>
            </div>
            <div class="form-group has-feedback clearfix ">
                <label class="control-label col-sm-3 pt0" for="introduction">内容：</label>
                <div class="col-sm-9">
                    <textarea class="form-control" rows="3" id="content" placeholder="内容"></textarea>
                </div>
            </div>
            <div class="form-group clearfix">
                <div class="col-sm-9 col-sm-offset-3">
                    <button type="button" class="king-btn mr10  king-success" onclick="save_record(this)">提交</button>
                    <button type="button" class="king-btn king-default ">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="king-block king-block-bordered king-block-themed m20">
    <div class="king-block-header king-info">
        <ul class="king-block-options">
            <li>
                <!-- <button type="button"><i class="fa fa-cog"></i></button> -->
            </li>
        </ul>
        <h3 class="king-block-title">会议信息展示</h3>
    </div>
    <div class="king-block-content">
        <div style="height:310px; overflow: auto;" id="list_1526104329322" class="king-list3 m0">
            <table class="king-list3-table ranger-box">
                <tbody></tbody>
            </table>
        </div>
        <!-- 设置面板Start -->
        <template id="ranger_nodata_tpl">
            <tr>
                <td colspan="3"> 没有数据 </td>
            </tr>
        </template>
        <template id="ranger_tpl">
            <tr>
                <td style="width:42px;">#index#</td>
                <td style="width:40%;">#theme#</td>
                <td>#content#</td>
            </tr>
        </template>
        <!-- 设置面板End -->
    </div>
</div>
</%block>
<script>
    function renderTpl(str, cfg) {
            var re = /(#(.+?)#)/g;

            return str.replace(re, function() {
                var val = cfg[arguments[2]]+'';
                if(typeof val == 'undefined') {
                    val = '';
                }
                return val;
            });
        }

    function initRanger(conf){
        // 异步请求后台数据
        $.ajax({
            url: conf.url,
            type: 'GET',
            dataType: conf.dataType,
            success: function(res){
                //获取数据成功
                if (res.code == 0){
                    var _html = ' ';
                    var list = res.data;
                    
                    var tpl = $('#ranger_tpl').html();
                    if (list.length == 0){
                        _html = $('#ranger_nodata_tpl').html();
                    }else{
                        for (var i=0,len=list.length; i < len; i++){
                            var item = list[i];
                            _html += renderTpl(tpl, item)
                        }
                    }
                    $(conf.container).html(_html);
                }
            }
        });
    }
    
    //保存会议数据
    function save_record(obj){
        var theme = $('#theme').val();
        var content = $('#content').val();
        $.post('${SITE_URL}iwork/save_record/', {'theme': theme, 'content': content}, function(data){
            if(data.result){
                initRanger({
                    url: '${SITE_URL}iwork/records/',
                    dataType: 'json',
                    container: '#list_1526104329322 .ranger-box tbody'
                });
            }else{
                alert(data.message)
            }
        }, 'json')
        return
    }
</script>
<script>
    //获取会议记录
    initRanger({
            url: '${SITE_URL}iwork/records/',
            dataType: 'json',
            container: '#list_1526104329322 .ranger-box tbody'
        });
</script>